﻿@{
    ViewBag.Title = "保存我的地址";
    Layout = "~/Views/Shared/_UsersCenterLayout.cshtml";
    ViewBag.NavTitle = "保存我的地址";
}
@using MvcMall.Portal.Controllers.Users.ViewModels;
@model SaveUserAddressModel
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        GetCountries();
        $('#Country').change(function () { GetProvince() });
        $("#Province").change(function () { GetCity() });
        $("#City").change(function () { GetDistrict() });
    });

    function GetCountries() {
        $('#Country').empty();
        $("#Province").empty();
        $("#City").empty();
        $("#District").empty();
        $("<option></option>")
                    .val("请选择")
                    .text("请选择")
                    .appendTo($('#Country'));

        $.getJSON("/Ajax/GetCountries", function (data) {
            $.each(data, function (i, item) {
                $("<option></option>")
                    .val(item["Value"])
                    .text(item["Text"])
                    .appendTo($('#Country'));
            });
        });
    }

    function GetProvince() {
        $("#Province").empty();
        $("#City").empty();
        $("#District").empty();
        $("<option></option>")
                    .val("请选择")
                    .text("请选择")
                    .appendTo($('#Province'));

        var url = "/Ajax/GetChildRegion/" + $('#Country').val();
        $.getJSON(url, function (data) {
            $.each(data, function (i, item) {
                $("<option></option>")
                    .val(item["Value"])
                    .text(item["Text"])
                    .appendTo($('#Province'));
            });
        });
    }

    function GetCity() {
        $("#City").empty();
        $("#District").empty();

        $("<option></option>")
                    .val("请选择")
                    .text("请选择")
                    .appendTo($('#City'));

        var url = "/Ajax/GetChildRegion/" + $('#Province').val();
        $.getJSON(url, function (data) {
            $.each(data, function (i, item) {
                $("<option></option>")
                    .val(item["Value"])
                    .text(item["Text"])
                    .appendTo($('#City'));
            });
        });
        
    }

    function GetDistrict() {
        $("#District").empty();
        $("<option></option>")
                    .val("请选择")
                    .text("请选择")
                    .appendTo($('#District'));
        var url = "/Ajax/GetChildRegion/" + $('#City').val();
        $.getJSON(url, function (data) {
            $.each(data, function (i, item) {
                $("<option></option>")
                    .val(item["Value"])
                    .text(item["Text"])
                    .appendTo($('#District'));
            });
        });      
    }
</script>
<div class="right_box">
    <div class="right_box_map">
        保存我的地址
    </div>
    @using (Html.BeginForm())
    {
        <table style="margin-top: 10px;" width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr height="40">
            @Html.HiddenFor(c => c.Id)
                <td class="tab2_td">
                    所属地区：
                </td>
                <td>
                    <select id="Country" name="Country" style="width: 80px">
                    </select>
                    <select id="Province" name="Province" style="width: 100px">
                    </select>
                    <select id="City" name="City" style="width: 100px">
                    </select>
                    <select id="District" name="District" style="width: 100px">
                    </select>
                </td>
                <td>
                   
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.Address)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.Address, new { @class = "tab_input", @style = " width:300px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.Address)
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.SendName)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.SendName, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.SendName)
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.ZipCode)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.ZipCode, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.ZipCode)
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.Mobile)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.Mobile, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.Mobile)
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.Phone)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.Phone, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.Phone)
                </td>
            </tr>
            <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.BestSendTime)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.BestSendTime, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.BestSendTime)
                </td>
            </tr>
             <tr height="40">
                <td class="tab2_td">
                    @Html.LabelFor(c => c.AddressLogo)：
                </td>
                <td>
                    @Html.TextBoxFor(c => c.AddressLogo, new { @class = "tab_input", @style = " width:150px;" })
                </td>
                <td>
                    @Html.ValidationMessageFor(c => c.AddressLogo)
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td colspan="2">
                    <input type="submit" value="保存地址" />
                </td>
            </tr>
        </table>
    }
</div>
